unit rst_Reciepts;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, shbl_Reestr, StdCtrls, Mask, DBCtrlsEh, DB, FIBDataSet,
  pFIBDataSet, ActnList, GridsEh, DBGridEh, fraAddress, ExtCtrls, ComCtrls,
  ToolWin, fraSubstanceInfo, FIBDatabase, pFIBDatabase, DBCtrls,
  PropFilerEh, PropStorageEh, XLSExportComp;

type
  TrstReciepts = class(TshblReestr)
    Label6: TLabel;
    dbtBdate: TDBDateTimeEditEh;
    Label1: TLabel;
    dbtEdate: TDBDateTimeEditEh;
    cbSelfOnly: TDBCheckBoxEh;
    ds_Detail: TpFIBDataSet;
    dsc_Detail: TDataSource;
    dbeReciept: TDBEditEh;
    Label2: TLabel;
    dsReferRRECIEPT: TFIBStringField;
    dsReferRSUMMA: TFIBBCDField;
    dsReferRABON_ID: TFIBIntegerField;
    dsReferRNLS: TFIBStringField;
    dsReferRTOWN: TFIBStringField;
    dsReferRSTREET_NAME: TFIBStringField;
    dsReferRHOUSE: TFIBStringField;
    dsReferRAPPARTS: TFIBIntegerField;
    dsReferRNAME: TFIBStringField;
    dsReferRZKX: TFIBStringField;
    dsReferRDATE: TFIBDateField;
    dsReferRCASHIER: TFIBStringField;
    dsReferRCORPS: TFIBStringField;
    dsReferRLETTER: TFIBStringField;
    ds_DetailID: TFIBIntegerField;
    ds_DetailPAY_NAME: TFIBStringField;
    ds_DetailDOGOVOR_ID: TFIBIntegerField;
    ds_DetailSUMMA: TFIBBCDField;
    ds_DetailGROUP_ID: TFIBIntegerField;
    ds_DetailREESTR: TFIBIntegerField;
    ds_DetailNAME: TFIBStringField;
  private
    { Private declarations }

    procedure FillFindParams;
  public
    { Public declarations }
  end;

var
  rstReciepts: TrstReciepts;

implementation

uses uMAIN, uDM;

{$R *.dfm}

procedure TrstReciepts.FillFindParams;
var i:integer;
begin
{
:PRECIEPT,
    :PBDATE,
    :PEDATE,
    :PHOUSE,
    :PAPPARTS,
    :PCLIENT_ID,
    :PZKX_ID,
    :PABONENT_ID,
    :PORG_ID,
    :PUSER_ID 

  with TfraAddress1 do begin
    if NLSEdit.Visible and dsRefer.ParamExist('PNLS',i) then
      dsRefer.ParamByName('PNLS').Value := NLSEdit.Text;
    if dsRefer.ParamExist('PNAME',i) then
      dsRefer.ParamByName('PNAME').Value := NameEdit.Text;
    if TownBox.Visible and dsRefer.ParamExist('PTOWN_ID',i) then
      dsRefer.ParamByName('PTOWN_ID').Value := TownBox.KeyValue;
    if StreetBox.Visible and dsRefer.ParamExist('PSTREET_ID',i) then
      dsRefer.ParamByName('PSTREET_ID').Value := StreetBox.KeyValue;
    if HouseBox.Visible and dsRefer.ParamExist('PHOUSE',i) then
      dsRefer.ParamByName('PHOUSE').Value := HouseBox.Text;

    dsRefer.ParamByName('PAPPARTS').Clear;
    dsRefer.ParamByName('PLETTER').Clear;

    if AppartBox.Visible and dsRefer.ParamExist('PAPPARTS',i) then
      dsRefer.ParamByName('PAPPARTS').Value := QAppartsAPPARTS.Value;
    if AppartBox.Visible and dsRefer.ParamExist('PLETTER',i)
      and not QAppartsLETTER.IsNull then
      dsRefer.ParamByName('PLETTER').Value := QAppartsLETTER.Value;
  end;

  if dsRefer.ParamExist('PTYPE',i) then
  begin
    dsRefer.ParamByName('PTYPE').Clear;
    if cbMaType.KeyValue <> 0 then dsRefer.ParamByName('PTYPE').Value := cbMaType.KeyValue;
  end;

  if dsRefer.ParamExist('PACTIVE',i) then
    dsRefer.ParamByName('PACTIVE').AsBoolean := not(cbClosedLS.Checked);

  if dsRefer.ParamExist('PMANAME',i) then
    dsRefer.ParamByName('PMANAME').Value := dbeMaName.Text;

  if cbServices.KeyValue > 0 then
    dsRefer.ParamByName('addparam').Value := 'group_id='+VarToStr(cbServices.KeyValue)
  else
    dsRefer.ParamByName('addparam').Clear;       }
end;

end.
